﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PlottingBasics.Functions;
using PlottingBasics.Axis;
using System.Linq;

namespace t_PlottingBasics
{
    [TestClass]
    public class t_Gaussian
    {
        [TestMethod]
        public void TestGaus()
        {
            Assert.IsTrue(Gaussian.Gauss(0.0, 1.0)(0.0) > 0.3, "Gaussian isn't right");
            Assert.IsTrue(Gaussian.Gauss(0.0, 1.0)(10.0) < 0.001, "Not right at small values");
        }

        [TestMethod]
        public void TestIntegral()
        {
            double delta = 40.0 / 1000;
            LinearAxis lx = new LinearAxis(1000, -20.0, 20.0);
            var allvalues = ApplyFunction.Apply(lx, Gaussian.Gauss(0.0, 1.0));
            var slices = from v in allvalues
                         select v.Y * delta;
            double total = slices.Sum();
            Assert.IsTrue(Math.Abs(1.0 - total) < 0.1, "Total isn't right - " + total.ToString());
        }
    }
}